//
//  JWRichTextView.h
//  JWRichTextViewDemo
//
//  Created by fuqiang on 2/26/14.
//  Copyright (c) 2014 fuqiang. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "JWRichTextRun.h"
#import "JWRichTextRunURL.h"
#import "JWRichTextRunEmoji.h"

@class JWRichTextView;

typedef NS_OPTIONS(NSUInteger, JWRichTextRunTypeList)
{
    JWRichTextRunNoneType  = 0,
    JWRichTextRunURLType   = 1 << 0,
    JWRichTextRunEmojiType = 1 << 1,
};

@protocol JWRichTextViewDelegate<NSObject>

@optional
- (void)richTextView:(JWRichTextView *)view touchBeginRun:(JWRichTextRun *)run;
- (void)richTextView:(JWRichTextView *)view touchEndRun:(JWRichTextRun *)run;
- (void)richTextView:(JWRichTextView *)view touchCanceledRun:(JWRichTextRun *)run;

@end

@interface JWRichTextView : UIView

@property(nonatomic,weak) id<JWRichTextViewDelegate> delegage;

@property (nonatomic,copy  ) NSString              *text;       // default is nil
@property (nonatomic,copy  ) NSMutableAttributedString *attributedText;
@property (nonatomic,strong) UIFont                *font;       // default is nil (system font 17 plain)
@property (nonatomic,strong) UIColor               *textColor;  // default is nil (text draws black)
@property (nonatomic       ) JWRichTextRunTypeList runTypeList;
@property (nonatomic)        CGFloat               rowSpace;

- (NSMutableAttributedString *)createAttributedStringWithText:(NSString *)text font:(UIFont *)font rowSpace:(CGFloat)rowSpace;

- (NSArray *)createTextRunsWithAttString:(NSMutableAttributedString *)attString runTypeList:(JWRichTextRunTypeList)typeList;

- (CGRect)boundingRectWithSize:(CGSize)size font:(UIFont *)font AttString:(NSMutableAttributedString *)attString;

- (CGRect)boundingRectWithSize:(CGSize)size font:(UIFont *)font string:(NSString *)string rowSpace:(CGFloat )rowSpace;

@end
